/* global Vue */
const { createApp } = Vue;
createApp({
  data() {
    return {
      msg: '',
      list: [
        {
          name: '茄子',
          common: '住在山里面,真不错~',
          good: 999,
          date: '2022-12-12',
        },
        {
          name: '大司马',
          common: '芜湖起飞~',
          good: 0,
          date: '2022-12-13',
        },
      ],
    };
  },
  methods: {
    submit() {
      if (this.msg == '') {
        alert('评论不能为空');
      } else {
        this.list.push({
          name: '游客1',
          common: this.msg,
          good: 0,
          date: new Date().toLocaleDateString().replace(/\//g, '-'),
        });
        this.msg = '';
      }
    },
  },
}).mount('#app');
